package com.dhj.yygh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dhj.yygh.mapper.HospitalSetMapper;
import com.dhj.yygh.model.hosp.HospitalSet;
import com.dhj.yygh.service.HospitalSetService;
import org.springframework.stereotype.Service;

/*
实现 HospitalSetService 接口，再继承 mybatis-plus 提供的 ServiceImpl ，其对 IService 接口中的方法做了实现、
并且，ServiceImpl 中也对泛型中指定的 Mapper 进行了自动注入，因此，自定义的 HospitalSetServiceImpl 无需再次注入对应的 Mapper
 */
@Service
public class HospitalSetServiceImpl
        extends ServiceImpl<HospitalSetMapper, HospitalSet>
        implements HospitalSetService {

    // 根据 hoscode 查询医院设置的 signKey
    @Override
    public String getHospitalSetSignKey(String hoscode) {

        QueryWrapper<HospitalSet> wrapper = new QueryWrapper<>();
        wrapper.eq("hoscode", hoscode);

        HospitalSet hospitalSet = baseMapper.selectOne(wrapper);
        return hospitalSet.getSignKey();
    }
}
